﻿using System;
using System.Diagnostics;

/*
 *  STACK           |   HEAP
 *  ef2|ef|ef       |
 *  ef|ef|ef        |
 *  cf|ref(cf)      |    cf
 *  y|int|1         |
 *  x|int|1         |
 */

namespace StructVSClass
{
    internal class Program
    {
        private static void Main(string[] args)
        {
            int x = 1;
            int y = 1;
            int[] valores = new[] { 1, 2 };

            ClaseFicha cf = new ClaseFicha();
            cf.X = 1;
            cf.Y = 1;
            cf.values = valores;

            ClaseFicha cf2 = cf;

            EstructuraFicha ef = new EstructuraFicha();
            ef.X = 1;
            ef.Y = 1;
            ef.values = valores;

            //TEST 1
            //Console.WriteLine("VALORES CLASS: X: " + cf.X + " Y:" + cf.Y);
            //Console.WriteLine("VALORES STRUCT: X: " + ef.X + " Y:" + ef.Y);

            //Actualizar(cf);
            //Actualizar(ef);
            //cf.Actualizar();
            //ef.Actualizar();
            //Console.WriteLine("ACTUALIZACION COMPLETADA");

            //Console.WriteLine("VALORES CLASS: X: " + cf.X + " Y:" + cf.Y);
            //Console.WriteLine("VALORES STRUCT: X: " + ef.X + " Y:" + ef.Y);

            //TEST 2
            valores[0] = 10;
            Console.WriteLine(cf.values[0]);
            Console.WriteLine(ef.values[0]);

            ActualizarArreglo(ef);
            Console.WriteLine(cf.values[0]);
            Console.WriteLine(ef.values[0]);

            Console.Read();
        }

        private static void ActualizarArreglo(EstructuraFicha est)
        {
            est.values[0] = 100;
        }

        private static void Actualizar(ClaseFicha claseFicha)
        {
            claseFicha.X = 2;
            claseFicha.Y = 2;
        }

        private static void Actualizar(EstructuraFicha ef2)
        {
            ef2.X = 2;
            ef2.Y = 2;
        }
    }

    public class ClaseFicha
    {
        public int X;
        public int Y;
        public int[] values;

        public void Actualizar()
        {
            this.X = 2;
            this.Y = 2;
        }
    }

    public struct EstructuraFicha
    {
        public int X;
        public int Y;
        public int[] values;

        public void Actualizar()
        {
            this.X = 2;
            this.Y = 2;
        }
    }
}